uniform vec2 chunk_pos;
uniform float wind;
uniform int underwater;

vec4 biome_grass = vec4(0.4, 0.8, 0.3, 1.0);

smooth out vec3 normal, vVertex, eyeVec;

void main(){
	vec4 pos = ge_VertexPosition;
	pos.xy += chunk_pos;
	ge_Color = vec4(1.0);
	ge_TexCoord0 = ge_VertexTexcoord;

	normal = ge_MatrixNormal * normalize(ge_VertexNormal);
	vVertex = vec3(ge_MatrixModelView * pos);
	eyeVec = -vVertex;

	if(ge_VertexColor.b == 1.0){
		ge_Color *= biome_grass;
	}

	float anim = wind * 2.0;
	if(ge_TexCoord0.z == 1.0){
		anim = (anim + 0.5) / 1.5;
		vec2 anim_v = (vec2(cos(ge_Time + pos.x * 0.1), sin(ge_Time + pos.y * 0.1)) + 1.0) / 2.0;
		anim = anim * length(anim_v);

		vec3 p = vec3(sin(ge_Time * 0.1), cos(ge_Time * 0.1), 0.0);
		pos.x += 0.75 * anim * p.x;
		pos.y += 0.75 * anim * p.y;
	}
	if(ge_TexCoord0.z == 2.0){
		vec2 anim_v = (vec2(cos(ge_Time + pos.x * 0.1), sin(ge_Time + pos.y * 0.1)) + 1.0) / 2.0;
		anim = anim * length(anim_v);

		vec3 p = vec3(sin(ge_Time * 0.1), cos(ge_Time * 0.1), 0.0);
		p.xy *= cos(pos.z * 20.0);
		pos.x += 0.4 * anim * p.x;
		pos.y += 0.4 * anim * p.y;
	}

	ge_Position = ge_MatrixProjection * ge_MatrixModelView * pos;
}